package com.nmsl.system.presc_temp.controller;

import com.nmsl.system.presc_temp.domain.PrescriptionMedicine;
import com.nmsl.system.presc_temp.service.IPrescriptionMedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/prescriptionMedicine")
public class PrescriptionMedicineController {
    @Autowired
    private IPrescriptionMedicineService prescriptionMedicineService;

    @GetMapping("/list")
    public List<PrescriptionMedicine> list(){
        return prescriptionMedicineService.getAllPrescriptionMedicines();
    }

    @PostMapping("/addmore")
    public int addmore(List<PrescriptionMedicine> prescriptionMedicine){
      return  prescriptionMedicineService.insertPrescriptionMedicines(prescriptionMedicine);
    }
    @PostMapping("/insert")
    public int insert(@RequestBody PrescriptionMedicine prescriptionMedicine){
        System.out.println(prescriptionMedicine);
        return  prescriptionMedicineService.insert(prescriptionMedicine);
    }

    @DeleteMapping("/delete")
    public int delete(@RequestParam("id") Long id){
        return prescriptionMedicineService.delete(id);
    }
}
